#include<iostream>
#include"Scanner.h"
#include"Parser.h"
#include"sqlUI.h"
using namespace std;
using namespace sql;

int sql::parse(const unsigned char* a, int len) {

	Scanner* scanner = new Scanner(a, len);
	Parser* parser = new Parser(scanner);
	parser->Parse();
	return parser->errors->count;
}

void sql::sqlUI() {
	string x;
	getline(cin, x);
	do {
		cout << "\nyadbms::sql>";
		getline(cin, x);
		if(strcmp(x.c_str(), "quit") == 0)
			break;
		unsigned char* y;
		y = (unsigned char*) x.data();
		if (parse(y, x.length()) != 0)
			cout << "\nInvalid SQL Syntax";

	} while (1);
}
